class StubpaymentsController < ApplicationController
  def index
  end

  def payment

    #flash[:status] = "Payment approved"
    #redirect_to stubpayments_url

    hash = { :account_id => '508aa24fe4b096f709727535', :amount => params[:amount], :category_id => params[:category][:id] }
    myhash = {:payment => hash}
    options = { :body => myhash.to_json, :headers => { 'Content-Type' => 'application/json' }}
    response = HTTParty.post('http://172.20.45.119:3000/payments', options)

    a = response.as_json

    myresponse = a[0]['response']
    flash[:status] = myresponse

    redirect_to stubpayments_url
  end

end
